package com.jiazhong.boot.mvc.controller;

import com.jiazhong.boot.commons.bean.Users;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
// 参数传递问题
@Slf4j
@Controller
@RequestMapping("/second")
public class SecondController {

    @RequestMapping("/a")
    public String a(String name) {
        log.info("用户访问了SecondController的a方法！");
        log.info("name:{}", name);
        return "a";
    }

    @RequestMapping("/b")
    public String b(@RequestParam(name = "page", defaultValue = "1") int p) {
        log.info("用户访问了SecondController的b方法！");
        log.info("页码:{}", p);
        return "a";
    }

    @RequestMapping("/c")
    public String c(String name, int age, char gender) {
        log.info("用户访问了SecondController的c方法！");
        log.info("name:{},age:{},gender:{}", name, age, gender);
        return "a";
    }

    @RequestMapping("/d1")
    public String d1(Users user) {
        log.info("用户访问了SecondController的d1方法！");
        log.info("user:{}", user);
        return "a";
    }

    @RequestMapping("/d2")
    public String d2(@RequestBody Users user) {
        log.info("用户访问了SecondController的d2方法！");
        log.info("user:{}", user);
        return "a";
    }
}
